﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace ebc.patterns.tests
{
    [TestFixture]
    public class test_MessageDecomposer
    {
        [Test]
        public void Split_a_string_into_a_prefix_and_an_integer_suffix()
        {
            var sut = new MessageDecomposer<string, string, int>(
                (msg, out0, out1) =>
                    {
                        var parts = msg.Split('/');
                        out0(parts[0]);
                        out1(int.Parse(parts[1]));
                    });

            string result = "";
            sut.Out0 += s => result += s;
            sut.Out1 += d => result = d.ToString() + result;

            sut.In_Decompose("hello/42");

            Assert.AreEqual("42hello", result);
        }
    }
}
